# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=autogen
pkgver=5.18.12
pkgrel=2
pkgdesc="A tool designed to simplify the creation and maintenance of programs that contain large amounts of repetitious text"
arch=('i686' 'x86_64')
url="https://autogen.sourceforge.io/"
groups=('base-devel')
license=('GPL3')
makedepends=('gcc' 'gmp-devel' 'libcrypt-devel' 'libffi-devel' 'libgc-devel' 'libguile-devel' 'libxml2-devel')
depends=('gcc-libs' 'gmp' 'libcrypt' 'libffi' 'libgc' 'libguile' 'libxml2')
install=autogen.install
source=("https://ftp.gnu.org/gnu/${pkgname}/rel${pkgver}/${pkgname}-${pkgver}.tar.xz"{,.sig}
        autogen-5.18.1-msys2.patch
        autogen-5.18.12-fix-guile-iface.patch
        autogen-5.18.12-fix-guile-version-check.patch)
sha256sums=('be3ba62e883185b6ee8475edae97d7197d701d6b9ad9c3d2df53697110c1bfd8'
            'SKIP'
            'd4bfc04d85a1995ddd8e5c6a3c5b65504a4ef42b74e4c6416865e54cc188d52a'
            '933ee879a2851000d51d2496c6cd0915289bb4010c06cae8adadd6fd84b6fda9'
            '6281d5f49433237b7fcbb75077f1bc95bbc330b99d5e6096889a8d31aed05790')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/autogen-5.18.1-msys2.patch
  patch -p1 -i ${srcdir}/autogen-5.18.12-fix-guile-iface.patch
  patch -p1 -i ${srcdir}/autogen-5.18.12-fix-guile-version-check.patch

  autoreconf -i
}

build() {
  LDFLAGS+=' -Wl,--export-all-symbols'
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure \
    --build=${CHOST} \
    --host=${CHOST} \
    --prefix=/usr
  make all
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  #make -k check
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  if [ -d ${pkgdir}/usr/share/pkgconfig ]; then
    mv ${pkgdir}/usr/share/pkgconfig ${pkgdir}/usr/lib/
  fi
}
